from ronglian_sms_sdk import SmsSDK
import random
import redis

accId = 'dfasfasffdsfsdf'
accToken = 'asdasfdgdfgfdhfdgh'
appId = 'sdgfdghfhgfjfgjfgfh'

def send_message(mobile):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    # mobile = '手机号1,手机号2'
    code = random.randint(100000,999999)
    datas = (code, 5)
    resp = sdk.sendMessage(tid, mobile, datas)
    print(resp)
    # 将验证码存入redis
    rds = redis.Redis(password='123321')
    key = 'sms_%s' % mobile
    rds.set(key,code,ex=60 * 5)
    # 数据库关闭
    return resp
